﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Elixi_AntdUi
{
    public partial class MessageForms : Form
    {
        public bool submit;
        public bool _isEnabled = false;
        public bool _isAutoConfirm;
        private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();

        /// <summary>
        /// 消息窗体
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="msg">消息</param>
        /// <param name="isEnabled">是否成功/同意</param>
        public MessageForms(string title, string msg, bool isEnabled = false)
        {
            InitializeComponent();
            label_Message.Text = msg;
            pageHeader1.Text= title;
            _isEnabled = isEnabled;

            // 如果isEnabled为true，设置定时器自动关闭
            if (_isEnabled)
            {
                timer.Interval = 2500; // 2.5秒 = 2500毫秒
                timer.Tick += Timer_Tick;
                timer.Start();
            }
        }
        private void Timer_Tick(object sender, EventArgs e)
        {
            // 停止计时器
            timer.Stop();
            // 自动执行确定按钮的点击事件
            button_Success_Click(null, null);
        }

        private void button_Success_Click(object sender, EventArgs e)
        {
            
            if (_isEnabled)
            {
                
            }
            this.Dispose();
        }

        private void button_Error_Click(object sender, EventArgs e)
        {

            this.Dispose();
        }

      /*  // 重写Dispose方法以确保计时器被正确释放
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                timer?.Dispose();
            }
            base.Dispose(disposing);
        }*/
    }
}
